package com.bdth.service.impl;

import com.bdth.mapper.DeviceMapper;
import com.bdth.model.Device;
import com.bdth.service.IDeviceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.*;

@Service
public class DeviceServiceImpl extends BaseServiceImpl<Device> implements IDeviceService {

	@Autowired
	private DeviceMapper mapper;

	public List<Map> queryDeviceTree(Map map) throws Exception {
		return mapper.queryDeviceTree(map);
	}

	public List<Device> queryDeviceByIds(List<Integer> deviceIds) throws Exception {

		Map<String, Object> map = new HashMap<String, Object>();
		List<Device> result = new ArrayList<Device>();
		List<Device> allDevList = mapper.queryByMapList(map);
		Map deviceMap = new HashMap<>();
		for (Device d : allDevList) {
			deviceMap.put(d.getId(), d);
		}

		for (int i : deviceIds) {
			Device dep = (Device) deviceMap.get(i);
			result.add(dep);
		}
		return result;
	}


	public List<Device> queryByDepIds(List<Integer> depIds) {
		return mapper.queryByDepIds(depIds);
	}

	public List<Map> queryDevice(Map map) {
		return mapper.queryDevice(map);
	}

	@Override
	public Device queryBySimNo(String simNo) {
		return mapper.queryBySimNo(simNo);
	}

	public Device queryByEquipName(String equipName) {
		return mapper.queryByEquipName(equipName);
	}

	@Override
	public List<Map> queryMapDataByMapList(Map map) throws Exception {
		return mapper.queryMapDataByMapList(map);
	}

}
